package com.wsoft.oss.manager;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wsoft.oss.entity.OssFileEntity;
import com.wsoft.oss.mapper.OssFileMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author z001
 * @Date 2024/9/26 15:23
 */
@Service
public class OssFileManager extends ServiceImpl<OssFileMapper, OssFileEntity> {
    /**
     * 根据md5查询
     * @param md5
     * @return
     */
    public OssFileEntity getMd5(String md5) {
        if(StrUtil.isBlank(md5)){
            return null;
        }
        QueryWrapper<OssFileEntity> query = new QueryWrapper<>();
        query.lambda().eq(OssFileEntity::getMd5, md5);
        List<OssFileEntity> list = list(query);
        if(CollUtil.isEmpty(list)){
            return null;
        }else{
            return list.get(0);
        }

    }
}
